﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using servidorNASDAQ.sistemaExternoNASDAQ;

namespace servidorNASDAQ
{
    public partial class ConsolaControl : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["theSystem"] == null)
            {
                mainNASDAQ mainnq = new mainNASDAQ();

                TextBox1.Text += "Inicializando sistema externo....\n";

                mainnq.initOrdenesPendientes();
                mainnq.createTimer(15000);

                HttpContext.Current.Session["theSystem"] = mainnq;

                TextBox1.Text += "Inicialización hecha!\n";
            }
            else
            {
                TextBox1.Text += "Systema ya inicializado!\n";
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            ((mainNASDAQ)HttpContext.Current.Session["theSystem"]).stopUpdater();
            HttpContext.Current.Session["theSystem"] = null;
            TextBox1.Text += "Operaciones detenidas!!!\n";
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            ((mainNASDAQ)HttpContext.Current.Session["theSystem"]).startUpdater();
            TextBox1.Text += "Operaciones inicializadas!!!\n";
        }
    }
}
